/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/*
 * ImageViewerPanel.java
 *
 * Created on 14.07.2010, 15:29:37
 */

package de.editura.common.swing.imageviewer;

import javax.swing.JTextField;

/**
 *
 * @author kschmidtner
 */
public class ImageViewerPanel extends javax.swing.JPanel {

    /** Creates new form ImageViewerPanel */
    public ImageViewerPanel() {
        initComponents();
        imageCanvas.setImgVPanel(this);

    }

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        imageCanvas = new de.editura.common.swing.imageviewer.ImageCanvas();
        controllerPanel = new javax.swing.JPanel();
        naviControllerJPanel = new javax.swing.JPanel();
        toBottomBtn = new javax.swing.JButton();
        toUpBtn = new javax.swing.JButton();
        toLeftBtn = new javax.swing.JButton();
        toRightBtn = new javax.swing.JButton();
        jPanel1 = new javax.swing.JPanel();
        zoomInBtn = new javax.swing.JButton();
        nextImgBtn = new javax.swing.JButton();
        previmgBtn = new javax.swing.JButton();
        zoomOutBtn = new javax.swing.JButton();
        imgCanvasSizeTF = new javax.swing.JTextField();
        refreshBtn = new javax.swing.JButton();

        toBottomBtn.setText("down");
        toBottomBtn.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                toBottomBtnActionPerformed(evt);
            }
        });

        toUpBtn.setText("up");
        toUpBtn.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                toUpBtnActionPerformed(evt);
            }
        });

        toLeftBtn.setText("left");
        toLeftBtn.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                toLeftBtnActionPerformed(evt);
            }
        });

        toRightBtn.setText("right");
        toRightBtn.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                toRightBtnActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout naviControllerJPanelLayout = new javax.swing.GroupLayout(naviControllerJPanel);
        naviControllerJPanel.setLayout(naviControllerJPanelLayout);
        naviControllerJPanelLayout.setHorizontalGroup(
            naviControllerJPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, naviControllerJPanelLayout.createSequentialGroup()
                .addContainerGap()
                .addComponent(toLeftBtn)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(naviControllerJPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(toUpBtn, javax.swing.GroupLayout.PREFERRED_SIZE, 227, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(toBottomBtn, javax.swing.GroupLayout.PREFERRED_SIZE, 227, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(toRightBtn, javax.swing.GroupLayout.PREFERRED_SIZE, 83, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap())
        );
        naviControllerJPanelLayout.setVerticalGroup(
            naviControllerJPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(naviControllerJPanelLayout.createSequentialGroup()
                .addGap(35, 35, 35)
                .addComponent(toBottomBtn))
            .addGroup(naviControllerJPanelLayout.createSequentialGroup()
                .addContainerGap()
                .addComponent(toUpBtn))
            .addGroup(naviControllerJPanelLayout.createSequentialGroup()
                .addGap(17, 17, 17)
                .addComponent(toLeftBtn))
            .addGroup(naviControllerJPanelLayout.createSequentialGroup()
                .addGap(18, 18, 18)
                .addComponent(toRightBtn))
        );

        zoomInBtn.setText("Zoom in");
        zoomInBtn.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                zoomInBtnActionPerformed(evt);
            }
        });

        nextImgBtn.setText(">");
        nextImgBtn.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                nextImgBtnActionPerformed(evt);
            }
        });

        previmgBtn.setText("<");
        previmgBtn.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                previmgBtnActionPerformed(evt);
            }
        });

        zoomOutBtn.setText("Zoom out");
        zoomOutBtn.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                zoomOutBtnActionPerformed(evt);
            }
        });

        imgCanvasSizeTF.setText("H: - W: ");

        refreshBtn.setText("Refresh");
        refreshBtn.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                refreshBtnActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
        jPanel1.setLayout(jPanel1Layout);
        jPanel1Layout.setHorizontalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(zoomInBtn, javax.swing.GroupLayout.PREFERRED_SIZE, 86, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(refreshBtn))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel1Layout.createSequentialGroup()
                        .addComponent(zoomOutBtn, javax.swing.GroupLayout.PREFERRED_SIZE, 88, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                        .addComponent(previmgBtn)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(nextImgBtn))
                    .addComponent(imgCanvasSizeTF, javax.swing.GroupLayout.PREFERRED_SIZE, 294, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addContainerGap())
        );
        jPanel1Layout.setVerticalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(zoomInBtn)
                    .addComponent(zoomOutBtn)
                    .addComponent(previmgBtn)
                    .addComponent(nextImgBtn))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(imgCanvasSizeTF, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(refreshBtn))
                .addContainerGap(7, Short.MAX_VALUE))
        );

        javax.swing.GroupLayout controllerPanelLayout = new javax.swing.GroupLayout(controllerPanel);
        controllerPanel.setLayout(controllerPanelLayout);
        controllerPanelLayout.setHorizontalGroup(
            controllerPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, controllerPanelLayout.createSequentialGroup()
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addGroup(controllerPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                    .addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(naviControllerJPanel, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                .addContainerGap())
        );
        controllerPanelLayout.setVerticalGroup(
            controllerPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, controllerPanelLayout.createSequentialGroup()
                .addGap(0, 0, Short.MAX_VALUE)
                .addComponent(naviControllerJPanel, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap())
        );

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
        this.setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addComponent(controllerPanel, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(imageCanvas, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)))
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(imageCanvas, javax.swing.GroupLayout.DEFAULT_SIZE, 538, Short.MAX_VALUE)
                .addGap(24, 24, 24)
                .addComponent(controllerPanel, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
        );
    }// </editor-fold>//GEN-END:initComponents

    private void zoomInBtnActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_zoomInBtnActionPerformed
        imageCanvas.zoomIn();

    }//GEN-LAST:event_zoomInBtnActionPerformed

    private void zoomOutBtnActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_zoomOutBtnActionPerformed
        imageCanvas.zoomOut();
    }//GEN-LAST:event_zoomOutBtnActionPerformed

    private void toLeftBtnActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_toLeftBtnActionPerformed
        imageCanvas.moveLeft(imageCanvas.getZoomSensibility());
    }//GEN-LAST:event_toLeftBtnActionPerformed

    private void toRightBtnActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_toRightBtnActionPerformed
        imageCanvas.moveRight(-imageCanvas.getZoomSensibility());
    }//GEN-LAST:event_toRightBtnActionPerformed

    private void toUpBtnActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_toUpBtnActionPerformed
        imageCanvas.moveUp(imageCanvas.getZoomSensibility());
    }//GEN-LAST:event_toUpBtnActionPerformed

    private void toBottomBtnActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_toBottomBtnActionPerformed
        imageCanvas.moveDown(-imageCanvas.getZoomSensibility());
    }//GEN-LAST:event_toBottomBtnActionPerformed

    private void refreshBtnActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_refreshBtnActionPerformed
        imageCanvas.refreshAsStandard();
    }//GEN-LAST:event_refreshBtnActionPerformed

    private void nextImgBtnActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_nextImgBtnActionPerformed
        imageCanvas.showNextImage();
    }//GEN-LAST:event_nextImgBtnActionPerformed

    private void previmgBtnActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_previmgBtnActionPerformed
        imageCanvas.showPreviousImage();
    }//GEN-LAST:event_previmgBtnActionPerformed


    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JPanel controllerPanel;
    private de.editura.common.swing.imageviewer.ImageCanvas imageCanvas;
    private javax.swing.JTextField imgCanvasSizeTF;
    private javax.swing.JPanel jPanel1;
    private javax.swing.JPanel naviControllerJPanel;
    private javax.swing.JButton nextImgBtn;
    private javax.swing.JButton previmgBtn;
    private javax.swing.JButton refreshBtn;
    private javax.swing.JButton toBottomBtn;
    private javax.swing.JButton toLeftBtn;
    private javax.swing.JButton toRightBtn;
    private javax.swing.JButton toUpBtn;
    private javax.swing.JButton zoomInBtn;
    private javax.swing.JButton zoomOutBtn;
    // End of variables declaration//GEN-END:variables

    public ImageCanvas getImageCanvas() {
        return imageCanvas;
    }

    public void setImageCanvas(ImageCanvas imageCanvas) {
        this.imageCanvas = imageCanvas;
    }

    public JTextField getImgCanvasSizeTF() {
        return imgCanvasSizeTF;
    }

    public void setImgCanvasSizeTF(JTextField imgCanvasSizeTF) {
        this.imgCanvasSizeTF = imgCanvasSizeTF;
    }

    

}
